import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

void main() => runApp(const GestureDetectorWidget());

class GestureDetectorWidget extends StatelessWidget {
  const GestureDetectorWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Flutter Demo",
      theme: ThemeData(
        primaryColor: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(title: const Text("Flutter 手势识别Widget")),
        body: GestureDetector(
          child: const Text('手势识别'),
          onTap: () {
            if (kDebugMode) {
              print('点击');
            }
          },
          onDoubleTap: () {
            if (kDebugMode) {
              print('双击');
            }
          },
          onLongPress: () {
            if (kDebugMode) {
              print('长按');
            }
          },
          onHorizontalDragStart: (DragStartDetails details) {
            if (kDebugMode) {
              print('水平滑动');
            }
          },
        ),
      ),
    );
  }
}
